// Generated with RobotBuilder version 0.0.1
package org.usfirst.frc2876.Robot2013.commands;

import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.command.Command;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import org.usfirst.frc2876.Robot2013.Robot;

/**
 *
 */
public class ShootIdle extends Command {

    double startTime;
    double lastdpadvalue = 0;

    public ShootIdle() {
        // Use requires() here to declare subsystem dependencies
        // eg. requires(chassis);

        // The following variables are automatically assigned by
        // robotbuilder and will be updated the next time you export to
        // Java from robot builder. Do not put any code or make any change
        // in the following block or it will be lost on an update. To
        // prevent this subsystem from being automatically updated, delete
        // the following line.
        // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=REQUIRES
        requires(Robot.shooter);
        // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=REQUIRES
    }
    // Called just before this Command runs the first time

    protected void initialize() {
//        startTime = Timer.getFPGATimestamp();
//        SmartDashboard.putNumber("Timer", 0);
//        Robot.shooter.endFeeder();
//        SmartDashboard.putBoolean("isFeederOn", Robot.shooter.isFeederOn());
        lastdpadvalue = 0;
    }
    // Called repeatedly when this Command is scheduled to run

    protected void execute() {
//        double now = Timer.getFPGATimestamp();
//        double currentTime = now - startTime;
//        if (currentTime >= 2 && currentTime < 3) {
//            SmartDashboard.putNumber("Timer", currentTime);
//            Robot.shooter.endShooter();
//        }

        double val = Robot.oi.getXbox().getDpadX();
        if (val != lastdpadvalue) {
            System.out.println(val);
            if (val > .5) {
                Robot.shooter.incrementShooterSpeed();
                Robot.shooter.startShooter();
            } else if (val < -.5) {
                Robot.shooter.decrementShooterSpeed();
                Robot.shooter.startShooter();
            }
            lastdpadvalue = val;
        }
    }
    // Make this return true when this Command no longer needs to run execute()

    protected boolean isFinished() {
        return false;
    }
    // Called once after isFinished returns true

    protected void end() {
    }
    // Called when another command which requires one or more of the same
    // subsystems is scheduled to run

    protected void interrupted() {
        end();
    }
}
